package com.mit.wx.controller;

import com.mit.wx.entity.WxUser;
import com.mit.wx.service.WxUserService;
import com.mit.wx.vo.EasyUIDataGrid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 2018/10/9 Create by 郭文梁
 * UserController
 * 用户相关访问控制器
 *
 * @author 郭文梁
 * @date 2018/10/9
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {
    private final WxUserService wxUserService;

    @Autowired
    public UserController(WxUserService wxUserService) {
        this.wxUserService = wxUserService;
    }

    @GetMapping("/all")
    public List<WxUser> list() {
        return wxUserService.list();
    }

    @GetMapping("/page")
    public EasyUIDataGrid<WxUser> list(int page, int rows) {
        return EasyUIDataGrid.of(wxUserService.getCount(), wxUserService.list(page, rows));
    }

    @GetMapping("/ready-for-sending")
    public List<WxUser> readyForSending() {
        return wxUserService.ready4Sending();
    }
}
